import pickle
import json

d = dict(name='Bob', age=20, score=80)
# pickle.dumps()方法把任意对象序列化成一个bytes
print(pickle.dumps(d))
f = open('dump.txt', 'wb')
pickle.dump(d, f)
f.close()

ff = open('dump.txt', 'rb')
d = pickle.load(ff)
ff.close()
print(d)

# JSON
aa = json.dumps(d)
print(aa)



